﻿@using Microsoft.AspNetCore.Mvc.Localization
@using Microsoft.Extensions.Localization
@inject IViewLocalizer Localizer
@inject IStringLocalizer<SharedResource> SharedLocalizer
@{
    ViewBag.Title = Localizer["Title"].Value;
}
<div class="container">
    <h3 class="table-title">@Localizer["Title"]</h3>
    <div class="form-inline" style="margin: 1em 0">
        <div class="form-group">
            <input type="search" name="title" id="title" value="" placeholder="@Localizer["NoticeTitle"]" class="form-control" />
        </div>
        <button id="btnSearch" type="button" class="btn btn-primary">@SharedLocalizer["Search"]</button>
    </div>
    <div id="div_main">
    </div>
</div>
@section scripts{
    <script>
        var pageSize = 10, pageIndex = 1;

        function loadData(pIndex) {
            if (!pIndex) {
                pageIndex = 1;
            } else {
                pageIndex = pIndex;
            }
            $("#div_main").html('<br /><img src="/images/loading.gif" /> @(SharedLocalizer["LoadingTip"])');
            $.ajax({
                url: "/Home/NoticeList",
                data: {
                    "PageIndex": pageIndex,
                    "PageSize": pageSize,
                    "SearchItem1": $("#title").val()
                },
                success: function (data, status) {
                    if (status == "success") {
                        $("#div_main").html(data);
                    } else {
                        $("#div_main").html('');
                        layer.msg('@(SharedLocalizer["LoadDataException"])');
                    }
                }
            });
        }

        $("#btnSearch").on("click",
            function () {
                loadData();
            });
        $(function () {
            loadData();
        });
    </script>
}